<template>
  <div id="test-page">
    
          <div class="clock"><my-clock></my-clock></div>
          <div class="search-wrap">
            <el-input class="search" v-model="input" placeholder="搜索你想看的影片"></el-input>
            <el-button type="primary" size="medium" icon="el-icon-search" >搜索</el-button>
          </div>
          <div class="history">
            <h5>历史记录</h5>
            <div class="tags-box">
            <tags v-for="(item,index) in history" @click="onlinePlay(item)" :key='index' :title="item"></tags>
            </div>
          </div>
    
  </div>
</template>  

<script>
import myClock from "./myClock.vue";
import Tags from "./utils/colorTags.vue"

export default{
  name:'testPage',
  components:{myClock,Tags},
  data(){
    return{
      history:[]
    }
  },
  methods:{
    onlinePlay(title){
     console.log('xxxx')
    this.$store.commit('search',title)
    console.log(this.$store.state.searchTitle)
    this.$router.push('/video')
  }

  },
  mounted(){
    this.history=this.$store.state.history.slice()
    console.log(this.history)
    // 之后结合mongodb可以添加用户信息里的history
  },
  computed: {
  isFollow () {
    return this.$store.state.history;//需要监听的数据
  }
  },
  watch: {
  isFollow () {
    this.history=this.$store.state.history.slice()
    console.log(this.history)
  }

  }
}
</script>

<style>
html,body {
  height: 80vh;
}
#test-page {
 height: 80vh;
  position: relative;
}
.content {
   
} 
.clock{
  position: absolute;
  top: 30%;
  left: 50%;
}
.search-wrap{
  width: 50%;
  display: flex;
  position: absolute;
  top: 50%;
  left: 25%;
}
.history{
 
  position: absolute;
  top: 55%;
  left: 25%;
}
.tags-box{
  width: 300px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  
}

</style>